package com.dt76.smallloanbackendservice.controller.lhuaw;

import com.dt76.smallloanbackendservice.pojo.lhuaw.ArticleManagement;
import com.dt76.smallloanbackendservice.service.lhuaw.ArticleManagementService;
import com.dt76.smallloanbackendservice.utils.Page;
import com.dt76.smallloanbackendservice.utils.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/lhuaw")
public class ArticleManagementController {
    @Resource
    private ArticleManagementService articleManagementService;
    @RequestMapping("/qryAllArticle")
    @ResponseBody
    public List<ArticleManagement> qryAllArticle(){
        return articleManagementService.qryAllArticle();
    }
    @RequestMapping("/qryAllArticleAll")
    @ResponseBody
    public Page qryAllArticleAll(@RequestParam("pageIndex")  int pageIndex,
                                 @RequestParam("articleTitle") String articleTitle,
                                 @RequestParam("classification") String classification){
        System.out.println("成功调用远程");
        return articleManagementService.qryAllArticleAll(pageIndex, articleTitle, classification);
    }
    @RequestMapping("/delArticle")
    @ResponseBody
    public Result delArticle(@RequestParam("articleId")int articleId){
        System.out.println("成功调用删除方法，ArticleManagementService.delArticle>>>>>>>>");
        try {
            articleManagementService.delArticle(articleId);
            return new Result(true,"删除成功>>>");
        } catch (Exception e) {
            return new Result(false,"删除失败>>>");
        }
    }
}
